package com.enn.demo.core.service.impl.domain.model.person;

import com.enn.demo.core.service.impl.domain.model.ValueObject;

/**
 * @author kll
 * @date 2021/5/17
 */
public final class Age implements ValueObject<Age> {

    private Integer age;

    public Age(final Integer age) {
        if(age == null) {
            throw new IllegalArgumentException("用户age不能为空");
        }
        this.age = age;
    }

    public Integer getAge() {
        return age;
    }

    @Override
    public boolean sameValueAs(Age other) {
        return other != null && this.age.equals(other.age);
    }

    @Override
    public String toString() {
        return this.age.toString();
    }
}
